<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title id='record_name'>收款记录</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="__INDEX__/store/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__INDEX__/store/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/store/css/newsj.css" />
		<script type="text/javascript" src="__INDEX__/dist/jquery.min.js"></script>
		<script type="text/javascript" src="__INDEX__/js/menudown.js"></script>
	</head>
	<style>
		.skjj_nav2 .num em {
			font-size: 1.5rem;
		}
		
		.skjj_item .bt {
			padding-top: 1%;
			padding-bottom: 1%;
		}
		
		.skjj_list .num {
			font-size: 1rem;
			padding-bottom: 2%;
		}
		
		.skjj_nav li {
			padding-top: 4%;
			padding-bottom: 3%;
		}
	</style>

	<body style="background: white;">
		<header class="mui-bar mui-bar-nav">
			<a style="text-decoration: none;" class=" mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
			<h1 class="mui-title" id='record_name1'>收款记录</h1>
		</header>
		<div class="mui-content sjindexcon">
			<ul class="report_nav skjj_nav clearfix">
				<li class="one" data-id=1>
					<a>今天</a>
				</li>
				<li data-id=2 class="two">
					<a>昨天</a>
				</li>
				<li data-id=3 class="three">
					<a>本周</a>
				</li>
				<li data-id=4 class="four">
					<a>自定义</a>
				</li>
			</ul>
			<ul class="skjj_nav2 clearfix">
				<li>
					<p class="bt">交易金额</p>
					<p class="num money">¥<em></em></p>
				</li>
				<li>
					<p class="bt">交易笔数</p>
					<p class="num bs"><em></em></p>
				</li>
				<li>
					<p class="bt">鼓励金</p>
					<p class="num glj">+<em></em></p>
				</li>
			</ul>
			<div class="skjj_item">
				<div class="bt time"> </div>
				<ul class="skjj_list">

				</ul>
			</div>
		</div>
		<input type="hidden" id="page" value="1" />
		<input type="hidden" id="type" value="0" />
	</body>

</html>
{include file="public/footer" /}
<script src="__PUBLIC__/static/js/mui.min.js"></script>
<script>
	$(".report_nav li").click(function() {
		var v = $(this).data("id");
		$("#type").val(v);
		$("#page").val(1);
		get_data();
	})
	get_data();

	function get_data() {
		$.ajax({
			type: "post",
			data: {
				type: $("#type").val(),
				page: $("#page").val()
			},
			url: "{:url('store/wallet/records')}",
			success: function(data) {  
				$('.money em').text(data.money.money);
				$('.bs em').text(data.id.ids);
				$('.glj em').text(data.zsscore);
				$('.time').text(data.time);
				if(data.type == 1){
					$('.two,.four,.three').removeClass('active');
					$('.one').addClass('active');
				}
				if(data.type == 2){
					$('.one,.four,.three').removeClass('active');
					$('.two').addClass('active');
				}
			    if(data.type == 3){
					$('.one,.four,.two').removeClass('active');
					$('.three').addClass('active');
				}
			    if(data.type == 4){
					$('.one,.two,.three').removeClass('active');
					$('.four').addClass('active');
				}
				var list = data.list;
				var html = "";
				if(list) {
					for(var i = 0; i < list.length; i++) {
						var log = list[i];
						var typename = '';
						if(log.pay_type == 1) {
							typename = '现金收款';
						} else if(log.pay_type == 2) {
							typename = '微信收款';
						} else {
							typename = '支付宝收款';
						}
						html += '<li>' +
							'<div class="left">' +
							'<p class="num">' + typename + '</p>' +
							'<p class="time">' + log.add_time + '</p>' +
							'</div>' +
							"<div class='center'>" +
							"<p class='nam'>金额</p>" +
							"<p class='time'>" + '+' + log['balance'] + "</p>" +
							"</div>" +
							"<div class='right'>" +
							"<p class='nam'>鼓励金</p>" +
							"<p class='time'>" + log['agent_score'] + "</p>" +
							"</div>"
						'</li>'
					}
				} else {
					html = "没有记录";
				}
				$(".skjj_list").html(html);

			}
		});
	}
	$(window).scroll(function() {
		var scrollTop = $(window).scrollTop(); //滚动条高度
		var bodyheight = $(document).height(); //文档的高度
		var windowheight = window.innerHeight; //$(window).height();              //当前窗体的高度
		if((bodyheight - windowheight - scrollTop) == 0) {
			$.ajax({
				type: "post",
				data: {
					page: parseFloat($("#page").val()) + 1
				},
				url: "{:url('store/wallet/records')}",
				success: function(data) {
					var list = data.list;
					var html = "";
					if(list) {
						$("#page").val(parseFloat($("#page").val()) + 1);
						for(var i = 0; i < list.length; i++) {
							var log = list[i];
							var typename = '';
							if(log.pay_type == 1) {
								typename = '现金收款';
							} else if(log.pay_type == 2) {
								typename = '微信收款';
							} else {
								typename = '支付宝收款';
							}
							html += '<li>' +
								'<div class="left">' +
								'<p class="num">' + typename + '</p>' +
								'<p class="time">' + log.add_time + '</p>' +
								'</div>' +
								"<div class='center'>" +
								"<p class='nam'>金额</p>" +
								"<p class='time'>" + '+' + log['balance'] + "</p>" +
								"</div>" +
								"<div class='right'>" +
								"<p class='nam'>鼓励金</p>" +
								"<p class='time'>" + log['agent_score'] + "</p>" +
								"</div>"
							'</li>'
						}
					} else {
						html = "已经到最后";
					}
					$(".skjj_list").append(html);

				}
			});

		}
	})
</script>